import { ResDataType, fetchWrapper } from './common';
import type { ResponseKey } from './group';

export type KeyActionAddParams = {
	date: string;
	kaCustomer: string;
	marketingPlan: string;
	productCapacityBuilding: string;
	id?: string | number;
	groupCode: ResponseKey;
};

export const keyActionAddApi = (
	url: string,
	{ arg }: { arg: KeyActionAddParams }
) => {
	return fetchWrapper<ResDataType>(url, arg, 'POST');
};
export const keyActionEditApi = (
	url: string,
	{ arg }: { arg: Required<KeyActionAddParams> }
) => {
	return fetchWrapper<ResDataType>(url, arg, 'POST');
};

export type TargetEditParams = {
	date: string;
	groupCode: string;
	indicatorName?: string;
	label?: string;
	val: string;
};

export const targetEditApi = (
	url: string,
	{
		arg
	}: {
		arg: TargetEditParams;
	}
) => {
	return fetchWrapper<ResDataType>(url, arg, 'POST');
};

export type KeyActionItem = {
	createBy: string;
	createTime: string;
	marketingPlan: string;
	productCapacityBuilding: string;
	kaCustomer: string;
	id: string | number;
	createByName: string;
};

export const keyActionListApi = (url: string) => {
	return fetchWrapper<KeyActionItem[]>(url);
};

export const keyActionDetailApi = (url: string) => {
	return fetchWrapper<KeyActionItem>(url);
};

